package com.zrrd.jt_admin.set.express.controller;


import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.zrrd.jt_admin.common.entity.ExpressCompany;
import com.zrrd.jt_admin.common.response.ResponseResult;
import com.zrrd.jt_admin.common.page.ExpressCompanyPageVo;
import com.zrrd.jt_admin.set.express.service.ExpressCompanyService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author wanjl
 * @since 2024-07-10
 */
@RestController
@RequestMapping("/admin/expressCompany")
@ResponseBody
public class ExpressCompanyController {

    @Resource
    private ExpressCompanyService expressCompanyService;

    @GetMapping("/{page}")
    public ResponseResult findByPage(@PathVariable("page") Integer page,
                                     @RequestParam(value = "limit",required = false,defaultValue = "10") Integer limit) {
        PageHelper.startPage(page,limit);
        List<ExpressCompany> list = expressCompanyService.list();
        PageInfo<ExpressCompany> pageInfo = new PageInfo<>(list);
        ExpressCompanyPageVo expressCompanyPageVo = new ExpressCompanyPageVo();
        expressCompanyPageVo.setList(list);
        expressCompanyPageVo.setTotalCount(pageInfo.getTotal());
        return ResponseResult.queryResponse(expressCompanyPageVo);
    }
}

